﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ReadCard</title>
     <script src="<%=Url.Content("~/Scripts/jquery-1.4.1.js") %>" type="text/javascript"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div>
    <input  type="button" value="读卡" class="button2" onclick="RfidCardReadSectorData()"/>
    <input name="button3" type="button" id="btn1" onclick="CardInOver()" value="进卡" class="button2"/>
    <input name="button5" type="button" id="btn2" onclick="Dischange()" value="退卡" class="button2"/>
     
    </div>
     <p>
  <object classid="clsid:2323E9E1-2B2E-4BD2-9F66-1C2D02F7A29C" codebase="vcp400.cab" width="0" height="0" id="vcp400">
  </object>
</p>
</body>
</html>
<script type="text/javascript">
    function RfidCardReadSectorData() {
        var hComm = 0;

        hComm = GetCOM();

       // nSector = document.getElementById('txtsector2').value;
       // sKey = document.getElementById('txtkey3').value;
      //  nkeymodel = 0;
       // nReturnHex = 1;
       // nWaittime = 15;

        /*
        hComm  端口
        nSector 扇区号（0 - 15）
        nkeymodel 密码类型
        sKey   密码，必须 6 位，空字符串时是原始密码

        返回成功读到的字符串，空表明出错或无数据
        */
        sData = vcp400.RfidCardReadSectorData(hComm, 0, 0, "", 15);

        alert(sData);

        vcp400.ocx_CommClose(hComm);
    }
    //进卡
    function CardInOver() {
        var hComm = 0;

        hComm = GetCOM();

        vcp400.CardInOver(hComm, 10); 	// 进卡

        vcp400.ocx_CommClose(hComm);

    }
    // 退卡	
    function Dischange() {
        var hComm = 0;

        hComm = GetCOM();

        vcp400.Dischange(hComm, 1, 10); 	// 0=不完全退卡,1=完全退卡

        vcp400.ocx_CommClose(hComm);

    }
    function GetCOM() {
        COM = 100;
        Baud = 57600;

        return vcp400.ocx_commopen(COM, Baud);
    }
</script>